﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcreport.Web.userinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int uid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(uid);
				}
			}
		}
			
	private void ShowInfo(int uid)
	{
		lcreport.BLL.userinfo bll=new lcreport.BLL.userinfo();
		lcreport.Model.userinfo model=bll.GetModel(uid);
		this.lbluid.Text=model.uid.ToString();
		this.txtuname.Text=model.uname;
		this.txtupwd.Text=model.upwd;
		this.txtutruename.Text=model.utruename;
		this.txtusex.Text=model.usex;
		this.txtudiqu.Text=model.udiqu;
		this.txtuadd.Text=model.uadd;
		this.txtuemail.Text=model.uemail;
		this.txtutel.Text=model.utel;
		this.txtuCID.Text=model.uCID;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtuname.Text.Trim().Length==0)
			{
				strErr+="用户名不能为空！\\n";	
			}
			if(this.txtupwd.Text.Trim().Length==0)
			{
				strErr+="密码不能为空！\\n";	
			}
			if(this.txtutruename.Text.Trim().Length==0)
			{
				strErr+="真实姓名不能为空！\\n";	
			}
			if(this.txtusex.Text.Trim().Length==0)
			{
				strErr+="性别不能为空！\\n";	
			}
			if(this.txtudiqu.Text.Trim().Length==0)
			{
				strErr+="地区不能为空！\\n";	
			}
			if(this.txtuadd.Text.Trim().Length==0)
			{
				strErr+="联系地址不能为空！\\n";	
			}
			if(this.txtuemail.Text.Trim().Length==0)
			{
				strErr+="邮箱不能为空！\\n";	
			}
			if(this.txtutel.Text.Trim().Length==0)
			{
				strErr+="电话不能为空！\\n";	
			}
			if(this.txtuCID.Text.Trim().Length==0)
			{
				strErr+="身份证号不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int uid=int.Parse(this.lbluid.Text);
			string uname=this.txtuname.Text;
			string upwd=this.txtupwd.Text;
			string utruename=this.txtutruename.Text;
			string usex=this.txtusex.Text;
			string udiqu=this.txtudiqu.Text;
			string uadd=this.txtuadd.Text;
			string uemail=this.txtuemail.Text;
			string utel=this.txtutel.Text;
			string uCID=this.txtuCID.Text;


			lcreport.Model.userinfo model=new lcreport.Model.userinfo();
			model.uid=uid;
			model.uname=uname;
			model.upwd=upwd;
			model.utruename=utruename;
			model.usex=usex;
			model.udiqu=udiqu;
			model.uadd=uadd;
			model.uemail=uemail;
			model.utel=utel;
			model.uCID=uCID;

			lcreport.BLL.userinfo bll=new lcreport.BLL.userinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
